package common.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import common.info.JsonBackInfo;
import core.exception.AccountingException;

/**
 * Created by Administrator on 2017/5/14.
 */
public class CatchAccountingExceptionInterceptor implements Interceptor{

    @Override
    public void intercept(Invocation invocation) {
        try {
            invocation.invoke();
        } catch (AccountingException e) {
            System.out.println("捕获到错误");
            invocation.getController().renderJson(new JsonBackInfo().fail(e.getMessage(), e.getData()));
        }

    }
}
